package com.saltlux.tdd.algorithm;

public class MinimumFinder {

	public int findIndexOfMinimumValue(int[] target) {
		return findIndexOfMinimumValue(target, 0);
	}

	public int findIndexOfMinimumValue(int[] target, int from) {
		int firstIndex = from;
		int minimumIndex = firstIndex;

		for(int i=firstIndex+1;i<target.length;i++){
			if(target[minimumIndex]>target[i]){
				minimumIndex =i;
			}	
		}

		return minimumIndex;
	}

	public int findIndexOfMinimumValue(Comparable[] fixture, int startIndex) {
		int minimumIndex = startIndex;
		
		for(int i=startIndex; i<fixture.length; i++) {
			if(fixture[i].compareTo(fixture[minimumIndex]) < 0) {
				minimumIndex = i;
			}
		}
		
		return minimumIndex;
	}
}
